RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -name=not_there_at_all - | \
RUN: FileCheck %s --check-prefix=EMPTY --allow-empty
EMPTY: {{^$}}

RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -name=main - | FileCheck %s
CHECK: : DW_TAG_subprogram
CHECK-NOT: {{:}}
CHECK:     DW_AT_name ("main")
CHECK-NOT: {{:}}

RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/libfat-test.a \
RUN:   -name=x86_64h_var -name=i386_var \
RUN:   | FileCheck %s --check-prefix=MULTI
MULTI: Mach-O 32-bit i386
MULTI-NOT: {{: DW}}
MULTI: : DW_TAG_variable
MULTI-NOT: {{: DW}}
MULTI:    DW_AT_name ("i386_var")
MULTI-NOT: {{: DW}}
MULTI: Mach-O 64-bit x86-64
MULTI: : DW_TAG_variable
MULTI-NOT: {{: DW}}
MULTI:    DW_AT_name ("x86_64h_var")
MULTI-NOT: {{: DW}}

RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -name=int - | FileCheck %s --check-prefix=TYPES
TYPES: : DW_TAG_base_type
TYPES-NOT: {{:}}
TYPES:     DW_AT_name ("int")
TYPES-NOT: {{:}}

This is one where --name observably behaves different from --find.
RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/odr-anon-namespace/1.o \
RUN:    -name="(anonymous namespace)" \
RUN:   | FileCheck %s --check-prefix=EMPTY

Test the -ignore-case option.
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -name=Main - | FileCheck %s -check-prefix=EMPTY
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -name=Main -i - | FileCheck %s
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -name=MAIN -ignore-case - | FileCheck %s

Test the -regex option.
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -regex -name=m.+n - | FileCheck %s
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -x -name=m.+n - | FileCheck %s
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -x -i -name=M.+n - | FileCheck %s
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | not llvm-dwarfdump -x -name=+ - 2>&1 | FileCheck %s --check-prefix=ERR
ERR: error
RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/libfat-test.a \
RUN:   -x -name=x86_64h_var -name=i386_var \
RUN:   | FileCheck %s --check-prefix=MULTI
RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/libfat-test.a \
RUN:   -x -name=.*86.*_var \
RUN:   | FileCheck %s --check-prefix=MULTI

Test the -show-children behavior.
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
RUN:   | llvm-dwarfdump -name="brief.c" - | FileCheck %s -check-prefix=NOCHILDREN
NOCHILDREN: DW_AT_name ("brief.c")
NOCHILDREN-NOT: DW_TAG

Test that --name also searches in DW_AT_linkage_name.
RUN: llc -O0 %S/statistics.ll -filetype obj -o - \
RUN:   | llvm-dwarfdump -name=_Z4cubei - | FileCheck %s --check-prefix=LINKAGE
LINKAGE: DW_AT_name	("cube")